<template>
  <view class="ikz-apply">
    <ikz-loading :css-data="loading_css"></ikz-loading>
    <view class="ikz-apply-item" v-for="(item,index) in show_info" :key="index">
      <view class="ikz-apply-head">
        <image class="ikz-apply-head-img" :src="item.avatar"></image>
        <view class="ikz-apply-name">
          {{item.nickname}}
        </view>
      </view>
      <view class="ikz-apply-list">
        <view class="ikz-apply-list-num">
          <view class="ikz-apply-list-num-title">
            接单数量
          </view>
          <view class="ikz-apply-list-num-num">
            {{item.receive_count}}
          </view>
        </view>
        <view class="ikz-apply-list-price">
          <view class="ikz-apply-list-price-title">
            带来的收益
          </view>
          <view class="ikz-apply-list-price-num">
            ￥{{item.profit}}
          </view>
        </view>
      </view>
    </view>
    <view class="ikz-more" v-if="load_more == 4">
      ——我也是有底线的——
    </view>
    <view class="ikz-more" v-if="load_more == 5">
      <image class="ikz-empty" src="/static/empty.png"></image>
    </view>
  </view>
</template>

<script>
  import ikzLoading from '@/pages/Component/Public/Loading/loading.vue';
  var app = getApp();
  import ikz from '@/pages/Common/tools.js';
  export default {
    components: {
      ikzLoading
    },
    data() {
      return {
        loading_css: {
          display: 'flex',
        },
        page:1,
        limit:10,
        load_more:2,
        show_info:[]
      }
    },
    onLoad(options){
      this.userInfo((res)=>{
        this.loading_css.display = 'none';
      })
    },
    onPullDownRefresh() {
      this.homeInfo(res=>{
      });
      this.page = 1;
      this.typeInfo((res)=>{
        uni.stopPullDownRefresh();
      });
    },
    onReachBottom() {
      if(this.load_more == 2){
        this.page++;
        this.load_more = 3;
        this.userInfo((res)=>{
        });
      }
    },
    methods: {
      userInfo(fn) {
        var path = '/xyb/agent/reveive_list';
        var data = {
          page:this.page,
          limit:10
        };
        ikz.post(path, data, res => {
            if(res.data.code){
              var temp_list = res.data.data.data;
              if(this.page != 1){
                for(var i = 0;i<temp_list.length;i++){
                  this.show_info.push(temp_list[i]);
                }
              }else{
                this.show_info = temp_list;
              }
              if(temp_list.length == this.limit){
                this.load_more = 2;
              }else{
                if(this.page == 1){
                  if(temp_list.length == 0){
                    this.load_more = 5;
                  }else {
                    this.load_more = 4;
                  }
                }else{
                  this.load_more = 4;
                }
              }
              this.$forceUpdate();
          }else{
            uni.showModal({
              title: '提示',
              content: res.data.msg,
              showCancel: false,
              success: function(res) {}
            });
          }
          fn();
          uni.hideLoading();
          // if(that.pull_status){
          // 	this.$emit("change",'pull');
          // }
        });
      },
    }
  };
</script>

<style>
  page {
    width: 100%;
    height: 100%;
    background: #F3F3F3;
    position: relative;
  }
  .ikz-apply-item{
    box-sizing: border-box;
    padding: 20rpx;
    width:95%;
    margin: 20rpx auto;
    background: #fff;
    border-radius: 15rpx;
  }
  .ikz-apply-head{
    display: flex;
    align-items: center;
  }
  .ikz-apply-head-img{
    width: 80rpx;
    height: 80rpx;
    border-radius: 50%;
  }
  .ikz-apply-name{
    margin-left: 20rpx;
  }
  .ikz-apply-list{
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 15rpx;
    font-size: 28rpx;
  }
  .ikz-apply-list-num{
    box-sizing: border-box;
    padding: 0 15rpx;
    width: 44%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #FBAB7E;
    border-radius: 15rpx;
    line-height: 80rpx;
    color: #fff;
  }
  .ikz-apply-list-price{
    box-sizing: border-box;
    padding: 0 15rpx;
    width: 54%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #F8C66D;
    border-radius: 15rpx;
    line-height: 80rpx;
  }
  .ikz-apply-list-num-num{
    font-weight: 600;
  }
  .ikz-apply-list-price-num{
    font-weight: 600;
  }
  .ikz-more{
    width:100%;
    text-align: center;
    line-height: 50rpx;
    color: #999999;
    padding-bottom: 25rpx;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 25rpx;
  }
  .ikz-empty{
    width: 150rpx;
    height: 150rpx;
    margin-bottom: 20rpx;
    margin-top: 150rpx;
  }
</style>
